package com.itheima.chapter09.io.charstream;

import java.io.UnsupportedEncodingException;
import java.util.Arrays;

//字符串编码问题
public class demo1 {
    public static void main(String[] args) {
        String s=  "黑那程序员";
        byte[] bys =s.getBytes();
        System.out.println(Arrays.toString(bys));
       /* byte[] bytes1 = s.getBytes("UTF-8");
        System.out.println(Arrays.toString(bytes1));*/
        byte[] bytes2;
        try {
            bytes2 = s.getBytes("gbk");
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
        System.out.println(Arrays.toString(bytes2));
        byte[] bts ={-23, -69, -111, -23, -126, -93, -25, -88, -117, -27, -70, -113, -27, -111, -104};
        String ss = new String(bts);
        System.out.println(ss);
        byte [] bts2 ={-70, -38, -60, -57, -77, -52, -48, -14, -44, -79};
        String ss2 = null;
        try {
            ss2 = new String(bts2,"gbk");
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
        System.out.println(ss2);
    }
}
